home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libio / fstream.h < prev    next >
C/C++ Source or Header  |  1993-11-26  |  3KB  |  82 lines

  1. /* This is part of libio/iostream, providing -*- C++ -*- input/output.
  2. Copyright (C) 1993 Free Software Foundation
  3.  
  4. This file is part of the GNU IO Library.  This library is free
  5. software; you can redistribute it and/or modify it under the
  6. terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU CC; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. As a special exception, if you link this library with files
  20. compiled with a GNU compiler to produce an executable, this does not cause
  21. the resulting executable to be covered by the GNU General Public License.
  22. This exception does not however invalidate any other reasons why
  23. the executable file might be covered by the GNU General Public License. */
  24.  
  25. #ifndef _FSTREAM_H
  26. #define _FSTREAM_H
  27. #ifdef __GNUG__
  28. #pragma interface
  29. #endif
  30. #include <iostream.h>
  31.  
  32. class fstreambase : virtual public ios {
  33.   public:
  34.     fstreambase();
  35.     fstreambase(int fd);
  36.     fstreambase(int fd, char *p, int l); /* Deprecated */
  37.     fstreambase(const char *name, int mode, int prot=0664);
  38.     void close();
  39.     filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }
  40.     void open(const char *name, int mode, int prot=0664);
  41.     int is_open() const { return rdbuf()->is_open(); }
  42.     void setbuf(char *ptr, int len) { rdbuf()->setbuf(ptr, len); }
  43. #ifdef _STREAM_COMPAT
  44.     int filedesc() { return rdbuf()->fd(); }
  45.     fstreambase& raw() { rdbuf()->setbuf(NULL, 0); return *this; }
  46. #endif
  47. };
  48.  
  49. class ifstream : public fstreambase, public istream {
  50.   public:
  51.     ifstream() : fstreambase() { }
  52.     ifstream(int fd) : fstreambase(fd) { }
  53.     ifstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/
  54.     ifstream(const char *name, int mode=ios::in, int prot=0664)
  55.     : fstreambase(name, mode, prot) { }
  56.     void open(const char *name, int mode=ios::in, int prot=0664)
  57.     { fstreambase::open(name, mode, prot); }
  58. };
  59.  
  60. class ofstream : public fstreambase, public ostream {
  61.   public:
  62.     ofstream() : fstreambase() { }
  63.     ofstream(int fd) : fstreambase(fd) { }
  64.     ofstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/
  65.     ofstream(const char *name, int mode=ios::out, int prot=0664)
  66.     : fstreambase(name, mode, prot) { }
  67.     void open(const char *name, int mode=ios::out, int prot=0664)
  68.     { fstreambase::open(name, mode, prot); }
  69. };
  70.  
  71. class fstream : public fstreambase, public iostream {
  72.   public:
  73.     fstream() : fstreambase() { }
  74.     fstream(int fd) : fstreambase(fd) { }
  75.     fstream(const char *name, int mode, int prot=0664)
  76.     : fstreambase(name, mode, prot) { }
  77.     fstream(int fd, char *p, int l) : fstreambase(fd, p, l) { } /*Deprecated*/
  78.     void open(const char *name, int mode, int prot=0664)
  79.     { fstreambase::open(name, mode, prot); }
  80. };
  81. #endif /*!_FSTREAM_H*/
  82.